import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		forcedLogin: false,
		hasLogin: false,
		userName: "",
		tabBar: [],
		tabBarIndex: 0
	},
	mutations: {
		login(state, userName) {
			state.userName = userName || '新用户';
			state.hasLogin = true;
		},
		logout(state) {
			state.userName = "";
			state.hasLogin = false;
		},
		changeTabBarIndex(state, value) {
			state.tabBarIndex = value
		},
		
		changeTabBar(state, value) {
			state.tabBar = value
		},
	},
	
	actions: {
		setTabBarIndex(context,value){
			context.commit('changeTabBarIndex',value)
		},
		setTabBar(context,value){
			context.commit('changeTabBar',value)
		}
	}
})

export default store
